﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TareaUno.Logica;

namespace TareaUno
{
    /// <summary>
    /// Lógica de interacción para MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
        {
            if (!String.IsNullOrEmpty(Textbox1.Text))
            {
                var user = ManejaDatos.GetUserByID(int.Parse(Textbox1.Text));
                if (user != null)
                {
                    Textbox2.Text = user.Nombrew;
                    Textbox3.Text = user.Alias;
                }
                else
                {
                    Textbox2.Text = "";
                    Textbox3.Text = "";
                }
            }
            else
            {
                Textbox2.Text = "";
                Textbox3.Text = "";
            }
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            bool result = ManejaDatos.SaveUser(int.Parse(Textbox1.Text), Textbox2.Text, Textbox3.Text);

            if (result)
                MessageBox.Show("Bien CHT! :)");
            else
                MessageBox.Show("VO NO EXISTES :(");
        }
    }
}
